package basic.tutorial.form;

import java.util.ArrayList;
import java.util.List;

/*
 *  Clasa statica folosita pentru retinerea informatiilor
 *  adaugate in AddForm, ce pot fi accesate de ViewForm
 */

public class Entry {
	
	private static List<Item> books = new ArrayList<Item>();
	
	private Entry(){}
	
	// Adaugarea informatiilor se poate face prin doua functii,
	// direct cu obiectul Item sau folosint componentele acestuia.
	public static void addEntry(String title, String author, int pageNo, int year){
		Item n = new Item();
		n.author = author;
		n.title = title;
		n.pageNo = pageNo;
		n.year = year;
	  
		books.add(n);	
	}

	public static void addEntry(Item nI){
		books.add(nI);	
	}
	
	// Obtinerea intrarii de la index-ul primit ca parametru
	public static Item getEntry(int index){
		return books.get(index);
	}
	
	// Lungimea listei
	public static int size(){
		return books.size();
	}
	
	// Lista cu autorii deja inregistrati
	public static ArrayList<String> getAuthors(){
		ArrayList<String> authors = new ArrayList<String>();
		
		int i;
		for( i = 0; i < books.size(); i++ )
			authors.add(books.get(i).author);
		
		return authors;
	}

}
